const { runExecutablesInParallel, sendMultipleSocketRequests } = require('../../../common')
const path = require('path')
const { basePath } = require('../../../config')
const { error } = require('console')

// let data = [
//     {
//         "path": path.join(basePath, "..\\dist\\main.exe"),
//         "args": { "task_name": "task", "args": "111" }
//     },
//     {
//         "path": path.join(basePath, "..\\dist\\main.exe"),
//         "args": { "task_name": "tiktok", "args": "222" }
//     },
//     {
//         "path": path.join(basePath, "..\\dist\\main.exe"),
//         "args": { "task_name": "init_chrome_driver" }
//     }
// ]

let data = [
    {
        "port": 8888,
        "message": { "task_name": "task", "args": "111" }
    },
    {
        "port": 8888,

        "message": { "task_name": "tiktok", "args": "222" }
    },
    {
        "port": 8888,
        "message": { "task_name": "init_chrome_driver" }
    }
]

async function VueMessage(event, arg) {
    console.log('Received message from Vue:', arg)
    // runExecutablesInParallel(data).then(results => {
    //     console.log(results)
    //     event.returnValue = results
    // }).catch(error => {
    //     console.error('Failed to get results:', error)
    // });
    messages = await sendMultipleSocketRequests(data).catch(error => {
        console.error('Failed to get results:', error)
    })
    event.returnValue = messages
    console.log(messages)
}

module.exports = {
    VueMessage
}